<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('事件管理列表')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input id="spEvtTypeId" name="spEvtTypeId" style="display: none;" />
                    <input id="ownerDeptId" name="ownerDeptId" style="display: none;" />

                    <div class="select-list">
                        <ul>
                            <li>
                                <label>事件编号：</label>
                                <input type="text" name="bh"/>
                            </li>
                            <li>
                                <label>事件描述：</label>
                                <input type="text" name="contents"/>
                            </li>
                            <li>
                                <label>办结回复：</label>
                                <input type="text" name="completeFeedback"/>
                            </li>
                            <li>
                                <label>结案回复：</label>
                                <input type="text" name="endFeedback"/>
                            </li>
                            <li>
                                <label>事件类型：</label>
                                <input type="text" id="evtTypeName" name="evtTypeName" onclick="selectEvtTypeTree()">
                            </li>
                            <li>
                                <label>办结组织：</label>
                                <input type="text" name="doneDeptFullTxt"/>
                            </li>
                            <li>
                                <label>结案组织：</label>
                                <input type="text" name="finishDeptFullTxt"/>
                            </li>
                            <li>
                                <label>所属组织：</label>
                                <input type="text" name="ownerDeptFullTxt"/>
                            </li>
                            <li>
                                <label>所属部门：</label>
                                <input type="text" id="ownerDeptName" name="ownerDeptName" onclick="selectDeptTree()">
                            </li>
                            <li class="select-time">
                                <label>登记时间： </label>
                                <input type="text" id="reportTimeStart" name="params[reportTimeStart]" class="time-input" placeholder="开始时间"/>
                                <span>-</span>
                                <input type="text" id="reportTimeEnd" name="params[reportTimeEnd]" class="time-input" placeholder="结束时间"/>
                            </li>
                            <li class="select-time">
                                <label>办结时间： </label>
                                <input type="text" id="doneTimeStart" name="params[doneTimeStart]" class="time-input" placeholder="开始时间"/>
                                <span>-</span>
                                <input type="text" id="doneTimeEnd" name="params[doneTimeEnd]" class="time-input" placeholder="结束时间"/>
                            </li>
                            <li>
                                <label>事件标签：</label>
                                <select id="tagId" name="tagId" th:with="type=${@dict.getType('evt_tag')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>数据来源：</label>
                                <select id="sourceId" name="sourceId" th:with="type=${@dict.getType('evt_source')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:evt:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="system:evt:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:evt:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:evt:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:evt:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/evt";
        var editFlag = [[${@permission.hasPermi('system:evt:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:evt:remove')}]];
        var tagDatas = [[${@dict.getType('evt_tag')}]];
        var sourceDatas= [[${@dict.getType('evt_source')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                viewUrl: prefix + "/view/{id}",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "事件",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'bh',
                    title: '事件编号',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:void(0)" onclick="$.operate.view(\'' + row.id + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'evtType1.typeName',
                    title: '一级分类'
                },
                {
                    field: 'evtType2.typeName',
                    title: '二级分类'
                },
                {
                    field: 'evtType3.typeName',
                    title: '三级分类',
                    formatter: function(value, row, index) {
                        if(value && value.length>20){
                            return $.common.sprintf("<span>%s...</span>", value.substring(0, 20));
                        } else {
                            return value;
                        }
                    }
                },
                {
                    field: 'contents',
                    title: '事件描述',
                    formatter: function(value, row, index) {
                        if(value && value.length>20){
                            return $.common.sprintf("<span>%s...</span>", value.substring(0, 20));
                        } else {
                            return value;
                        }
                    }
                },
                {
                    field: 'reportTime',
                    title: '登记时间'
                },
                {
                    field: 'doneTime',
                    title: '办结时间'
                },
                {
                    field: 'ownerDept.deptName',
                    title: '所属部门'
                },
                {
                    field: 'tagId',
                    title: '事件标签',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(tagDatas, value);
                    }
                },
                {
                    field: 'sourceId',
                    title: '数据来源',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sourceDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //选择事件类型
        function selectEvtTypeTree() {
            var spEvtTypeId = $.common.isEmpty($("#spEvtTypeId").val()) ? "1" : $("#spEvtTypeId").val();
            var url = ctx + "system/type/selectEvtTypeTree/" + spEvtTypeId;
            var options = {
                title: '选择事件类型',
                width: "380",
                url: url,
                callBack: selectEvtTypeTreeSubmit
            };
            $.modal.openOptions(options);
        }
        function selectEvtTypeTreeSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#spEvtTypeId").val(body.find('#treeId').val());
            $("#evtTypeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }

        //选择部门
        function selectDeptTree() {
            var deptId = $.common.isEmpty($("#reportDeptId").val()) ? "100" : $("#reportDeptId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: selectDeptTreeSubmit
            };
            $.modal.openOptions(options);
        }
        function selectDeptTreeSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#ownerDeptId").val(body.find('#treeId').val());
            $("#ownerDeptName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                &nbsp;<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>